﻿pb<link href="../../Content/zTreeStyle/zTreeStyle.css" rel="stylesheet" type="text/css" />
<script src="../../Scripts/zTree/jquery.ztree.core-3.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
    var zTree;
    var demoIframe;
    var setting = {
        view: {
            dblClickExpand: false,
            showLine: true,
            selectedMulti: false,
            expandSpeed: ($.browser.msie && parseInt($.browser.version) <= 6) ? "" : "fast"
        },
        data: {
            simpleData: {
                enable: true,
                idKey: "id",
                pIdKey: "pId",
                rootPId: ""
            }
        },
        callback: {
            beforeClick: function (treeId, treeNode) {
                var zTree = $.fn.zTree.getZTreeObj("tree");
                if (treeNode.isParent) {
                    alert("1");
                    return false;
                } else {
                    alert("2");
                    return true;
                }
            }
        }
    };
    var zNodes = @Html.Raw(ViewBag.TreeJsonStr) ;

    $(document).ready(function(){
        var t = $("#tree");
        t = $.fn.zTree.init(t, setting, zNodes);
        var zTree = $.fn.zTree.getZTreeObj("tree");
        zTree.selectNode(zTree.getNodeByParam("id", 101));
    });

</script>
<div>
    <ul id="tree" class="ztree" style="width: 260px; overflow: auto;">
    </ul>
</div>
